/*
 * ESFastForward.cs
 *
 * Created on November 17, 2007, 10:21 PM
 *
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 * Copyright (C) 2010       Mathijs Miermans
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Windows.Media;
using System.Windows.Shapes;

using HexTD.util;
using HexTD.sprite;

namespace HexTD.sprite
{
	public class ESFastForward : EnemySpriteBaseDirectional
	{

		private int prevPaintTime;
		private Color bodyColor = Color.FromArgb(255, 100, 150, 200);
		private Brush bodyStroke;
		private int bodyStep = 0;
		private static string infoText =
				"<h1>FastForward</h1>" +
				"<p>" +
				"It's going forward fast. Catch it if you can!<br>" +
				"</p>";

		protected override void doInit(Context context, int path, float delay, long health, int price, Size s)
		{
			base.doInit(context, path, delay, health * 8 / 10, price, s);
			this.speed = 100;        // * 1/1000 segments per tick
			this.speedMax = 100;     // * 1/1000 segments per tick
			this.speedMaxBase = 100; // * 1/1000 segments per tick
			this.power = 100;        // power > speedMax => speed = speedMax
			this.powerBase = 100;    // power > speedMax => speed = speedMax
		}

		public override string getInfostring()
		{
			return infoText +
					"<p>" + base.getInfostring() + "</p>";
		}

		/** Creates a new instance of ESFastForward */
		public ESFastForward()
			: base("Fast Forward")
		{
		}

		public override string getSvgName()
		{
			return null;
		}

		public override Shape[] generateShapes()
		{
			Shape[] shapes = null;
#if PORT
			Cache cache = this.context.getCache();
			if (cache.hasShapeArr("ESFFShapes" + this.size.letter))
			{
				shapes = cache.getShapeArr("ESFFShapes" + this.size.letter);
			}
			else
			{
				int frames = 16;
				shapes = new Shape[frames];

				double dr = 2.0 * Math.PI / frames;
				double r = 0;
				for (int i = 0; i < shapes.length; i++)
				{

					float scale = this.context.paintScale * this.size.scaleMod;
					float[,] points = {
						{scale * (-5.5f + 5 * (float) Math.Sin(-r)) / 24, +scale * (3.5f + 1.75f * (float) Math.Cos(-r)) / 24},
						{scale * (1.5f + 5 * (float) Math.Sin(-r)) / 24, +scale * (3.5f + 1.75f * (float) Math.Cos(-r)) / 24},
						{scale * (0.0f) / 24, 0},
						{scale * (5.5f) / 24, 0},
						{scale * (0.0f) / 24, 0},
						{scale * (1.5f + 5 * (float) Math.Sin(-r)) / 24, -scale * (3.5f + 1.75f * (float) Math.Cos(-r)) / 24},
						{scale * (-5.5f + 5 * (float) Math.Sin(-r)) / 24, -scale * (3.5f + 1.75f * (float) Math.Cos(-r)) / 24}
					};
					shapes[i] = Geometry.coordsToGeneralPath(points, false);
					r += dr;
				}
				cache.putShapeArr("ESFFShapes" + this.size.letter, shapes);
			}
#endif
			return shapes;
		}

		public override Brush generateStroke()
		{
#if PORT
			return new Brush(2.5f * this.context.strokeScale, Brush.CAP_ROUND, Brush.JOIN_ROUND);
#else
			return null;
#endif
		}

		public override Color generateColor()
		{
			return this.bodyColor;
		}
	}
}